#include <stdio.h>
#include <stdbool.h>
#include <math.h>
#define N 3009
int arr[N];
int binary_div_h(int num,int n)
{
	int l=-1,r=n;
	while(l+1<r)
	{                 //-1 0 1 2 3 4 5 6 7 8 
		int mid=(l+r)>>1;//1 2 3 4 5 5 6 8
		if(arr[mid]<num)
		{
			l=mid;
		}
		else r=mid;
	}
	if(arr[r]==num)
	{
		return r;
	}else return -1;
}
int binary_div_t(int num,int n)
{
	int l=-1,r=n;
	while(l+1<r)
	{
		int mid=(l+r)/2;
		if(arr[mid]<=num)l=mid;
		else r=mid;
	}
	if(arr[l]==num)return l;
	else return -1;
}
int main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++)scanf("%d",&arr[i]);
	while(q--)
	{
		int num;
		scanf("%d",&num);
		printf("%d %d\n",binary_div_h(num,n),binary_div_t(num,n));
	}
    return 0;
}
